package com.test.memcached;

import com.alisoft.xplatform.asf.cache.ICacheManager;
import com.alisoft.xplatform.asf.cache.IMemcachedCache;
import com.alisoft.xplatform.asf.cache.memcached.CacheUtil;
import com.alisoft.xplatform.asf.cache.memcached.MemcachedCacheManager;

/**
 * @功能描述 基于alisoft-xplatform-asf-cache-2.5.1
 * @time 2017-3-8
 * @author hugx
 * 
 */
public class AlisoftManager {
	private static ICacheManager<IMemcachedCache> cacheManager;
	private static AlisoftManager manager;

	private AlisoftManager() {
		cacheManager = CacheUtil.getCacheManager(IMemcachedCache.class, MemcachedCacheManager.class.getName());
		cacheManager.setConfigFile("memcached.xml");
		cacheManager.start();
	}

	/**
	 * 单态模式
	 * 
	 * @return
	 */
	public static AlisoftManager getInstance() {
		if (null == manager) {
			manager = new AlisoftManager();
		}
		return manager;
	}

	public void clusterCopy(String arg0, String arg1) {
		cacheManager.clusterCopy(arg0, arg1);
	}

	public IMemcachedCache getCache(String arg0) {
		return cacheManager.getCache(arg0);
	}

	public void reload(String arg0) {
		cacheManager.reload(arg0);
	}

	public void setResponseStatInterval(int arg0) {
		cacheManager.setResponseStatInterval(arg0);
	}

	public void stop() {
		cacheManager.stop();
	}
}